package com.shiguiwu.springboot3.filter;

import lombok.extern.slf4j.Slf4j;
import net.sf.jsqlparser.schema.Column;
import net.sf.jsqlparser.schema.Table;
import net.sf.jsqlparser.statement.Statement;
import net.sf.jsqlparser.statement.insert.Insert;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.Set;

/**
 * @description: 插入语句
 * @author: stone
 * @date: Created by 2023/7/21 20:46
 * @version: 1.0.0
 * @pakeage: com.shiguiwu.springboot3.filter
 */
@Component
@Slf4j
public class InsertFilter extends AbstractSqlFilter{



    @Override
    public boolean isSupport() {
        return this.getStatement() instanceof Insert;
    }

    @Override
    public void handleSql(Set<String> cols) {
        Insert insert = (Insert) this.getStatement();

        List<Column> columns = insert.getColumns();
        for (Column column : columns) {
            String columnName = column.getColumnName();
            cols.add(columnName);
        }
    }
}
